package stutterislandserver;

import core.Contact;
import core.ContactImpl;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Peter Nikodem
 */
public class UserDatabase {

    private final String databaseFile = "userDatabase";
    private final Map<String, Contact> contacts = new HashMap<String, Contact>();
    private final static UserDatabase db = new UserDatabase();

    public static Contact getContact(String contactId) {
        return db.contacts.get(contactId);
    }

    private UserDatabase() {
        loadUserConfiguration();
    }

    private void loadUserConfiguration() {
        String[] dab = {"derrick:rose", "john:wall", "kobe:bryant", "chris:andersen"};


        for (String s : dab) {
            String[] line = s.split(":");
            String user = line[0];
            String pass = line[1];
            contacts.put(user, new ContactImpl(user, pass));
        }
        System.err.println(contacts.size());

    }
}
